/**
 * Created by pkd on 14-3-19.
 */
var crypto = require('crypto')
var Codec = module.exports;

Codec.md5 = function (source) {
    if (!source) return '';
    if ('string' != typeof source) source = source + '';
    var md5sum = crypto.createHash('md5');
    md5sum.update(source, 'utf8');
    var encode = md5sum.digest('hex');
    return encode;
}

Codec.md5Check = function (md5, target) {
    var encode = this.md5(target);
    return encode == md5;
}